<?php
/**
 * Created by PhpStorm.
 * User: BeoBungBu
 * Date: 5/24/14
 * Time: 4:59 PM
 */
App::uses('Component', 'Controller');
class CaptchaComponent extends Component {



    public function checkCaptcha($captcha,$local=1){
        if(isset($_SESSION['captcha'])){
            if($captcha==$_SESSION['captcha']){
                if($local){
                    session_unset('captcha');
                    return true;
                }else{
                    echo json_encode(array('status'=>'true'));
                    session_unset('captcha');

                }
            }
        }
        if($local){
            session_unset('captcha');
            return false;
        }else{
            echo json_encode(array('status'=>'false'));
            session_unset('captcha');
            exit();
        }

    }
}